package com.sky.web.admin;


import com.sky.result.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/shop")
@Slf4j
public class ShopController {


    @Autowired
    private RedisTemplate redisTemplate;

    // 设置店铺的营业状态
    @PutMapping("/{status}")
    public Result updateStatus(@PathVariable("status") Integer status) {
        redisTemplate.opsForValue().set("SHOP_STATUS", status);//存到redis中
        log.info("更新店铺状态", status);
        return Result.success();
    }

    // 获取店铺的营业状态
    @GetMapping("/status")
    public Result getShopStatus() {
        Integer status = (Integer) redisTemplate.opsForValue().get("SHOP_STATUS");
        log.info("获取店铺状态",status);
        return Result.success(status);
    }


}
